/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.swta.freezay.database.dbEntities.copy;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Christian Baeumer
 */
@Entity
@Table(name = "PACKAGE")
@NamedQueries({@NamedQuery(name = "Package.findAll", query = "SELECT p FROM Package p"), @NamedQuery(name = "Package.findByName", query = "SELECT p FROM Package p WHERE p.name = :name"), @NamedQuery(name = "Package.findByDescription", query = "SELECT p FROM Package p WHERE p.description = :description"), @NamedQuery(name = "Package.findByPrice", query = "SELECT p FROM Package p WHERE p.price = :price"), @NamedQuery(name = "Package.findByDiscount", query = "SELECT p FROM Package p WHERE p.discount = :discount"), @NamedQuery(name = "Package.findByValidity", query = "SELECT p FROM Package p WHERE p.validity = :validity"), @NamedQuery(name = "Package.findByCount", query = "SELECT p FROM Package p WHERE p.count = :count")})
public class Package implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name = "ID")
    private int id;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @Column(name = "PRICE")
    private double price;
    @Basic(optional = false)
    @Column(name = "DISCOUNT")
    private double discount;
    @Basic(optional = false)
    @Column(name = "VALIDITY")
    @Temporal(TemporalType.TIMESTAMP)
    private Date validity;
    @Basic(optional = false)
    @Column(name = "COUNT")
    private int count;
    @ManyToMany(mappedBy = "packageCollection", fetch = FetchType.LAZY)
    private List<Item> itemCollection;
    @JoinColumn(name = "CATEGORY", referencedColumnName = "ID")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Category category;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "package1", fetch = FetchType.LAZY)
    private List<Reservation> reservationCollection;

    public Package() {
    }

    public Package(String name) {
        this.name = name;
    }

    public Package(String name, double price, double discount, Date validity, int count) {
        this.name = name;
        this.price = price;
        this.discount = discount;
        this.validity = validity;
        this.count = count;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getDiscount() {
        return discount;
    }

    public void setDiscount(double discount) {
        this.discount = discount;
    }

    public Date getValidity() {
        return validity;
    }

    public void setValidity(Date validity) {
        this.validity = validity;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public List<Item> getItemCollection() {
        return itemCollection;
    }

    public void setItemCollection(List<Item> itemCollection) {
        this.itemCollection = itemCollection;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public List<Reservation> getReservationCollection() {
        return reservationCollection;
    }

    public void setReservationCollection(List<Reservation> reservationCollection) {
        this.reservationCollection = reservationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (name != null ? name.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Package)) {
            return false;
        }
        Package other = (Package) object;
        if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "de.swta.freezay.database.dbEntities.Package[name=" + name + "]";
    }

}
